﻿
/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Input_HealthMemberHealthForm
 * 类型：       控制层
 * 功能说明：   会员健康情况信息页面
 * 作者：       徐傲明
 * 创建日期：   2008/02/22
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.System;
using log4net;
using Shpm.App.Commons.Utils;
using Shpm.System.Validator;
using Shpm.System.Web.Control;
public partial class App_Input_HealthMemberHealthForm : System.Web.UI.Page
{
    protected static ILog log = LogManager.GetLogger(typeof(App_Input_HealthMemberHealthForm));
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // 取得当前登录的用户id信息
            SysUserManager manager = new SysUserManager(Context);
            SysUserBean sysUserBean = manager.getSysUserBean();
            MstSysUserBean mstSysUserBean =
                sysUserBean == null ? null : sysUserBean.getMstSysUserBean();
            MstEmployeeBean mstEmpBean =
                sysUserBean == null ? null : sysUserBean.getEmployeeBean();
            string loginId = mstSysUserBean == null ? "" : mstSysUserBean.SysUserId;
            string emplyId = mstSysUserBean == null ? "" : mstSysUserBean.EmployeeId;
            string emplyJob = mstSysUserBean == null ? "" : mstEmpBean.EmployeeJob;
            string emplyLevel = mstSysUserBean == null ? "" : mstEmpBean.EmployeeLevel;
            string emplyRole = mstEmpBean == null ? "" : mstEmpBean.Role;
            ViewState["USER_ID"] = emplyId;
            string memberNo = Convert.ToString(Request.QueryString["MEMBER_NO"]);
            if (!string.IsNullOrEmpty(memberNo))
            {
                this.ViewState["MEMBER_NO"] = memberNo;
            }
            else
            {
                this.ViewState["MEMBER_NO"] = "A0010010101";
            }
            if (Context.Items.Contains("URL"))
            {
                this.ViewState["URL"] = Context.Items["URL"];
            }
            else
            {
                this.ViewState["URL"] = null;
            }
        }
     
        txtNameC.Text = Convert.ToString(this.ViewState["MEMBER_NO"]);
       
        HealthMemberHealthDao dao = new HealthMemberHealthDao();
        HealthMemberHealthBean bean = new HealthMemberHealthBean();
        HealthMemberHealthBean dataBean = new HealthMemberHealthBean();
        HealthMemberHealthBean timeBean = new HealthMemberHealthBean();
        
        if (!string.IsNullOrEmpty(Convert.ToString(this.ViewState["MEMBER_NO"])))
        {
            bean.MemberNo = Convert.ToString(this.ViewState["MEMBER_NO"]);
        }
        else
        {
            return;
        }

        //检索数据
        dataBean = dao.GetHealthMemberHealth(bean);
        timeBean = dao.GetTime(bean);
        IList list = dao.GetList(bean);
        IList ilist = dao.GetCureList(bean);
        
        //计算年龄
        int iAge = Convert.ToInt32(DateTime.Now.Year) - Convert.ToInt32(Convert.ToDateTime(dataBean.MemberBirthday).Year);
        //int iAge = Convert.ToInt32(age)+1;

        //显示数据
        txtAge.Text = Convert.ToString(iAge+1);
        if (dataBean != null)
        {
            txtNameC.Text = dataBean.MemberName;
            Sex.Text = dataBean.MemberSex;
            txtDisease.Text = dataBean.MemberDisease;
            txtDiseaseHis.Text = dataBean.MemberDiseaseHis;   
        }

        if (timeBean != null)
        {
            txtTime.Text = timeBean.MemberTime == null ? "" : DateUtils.convertToString((DateTime)timeBean.MemberTime);
        }
        viewMedicine.DataSource = list;
        viewMedicine.DataBind();
        viewRounds.DataSource = ilist;
        viewRounds.DataBind();
        this.memberNo.Value = Convert.ToString(this.ViewState["MEMBER_NO"]);
    }

    protected void viewMedicine_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //翻页
        viewMedicine.PageIndex = e.NewPageIndex;
    }

    protected void viewRounds_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //翻页
        viewRounds.PageIndex = e.NewPageIndex;
    }
}
